import usePermission from '@/store/modules/permission'
//自定义指令 按钮是否有权限
export default {
    mounted(el, binding) {
        const permissionStore = usePermission()
        const { value } = binding;
        if (value && value instanceof Array) {
            if (value.length > 0) {
                const hasPermission = permissionStore.hasPermisson(value[0]);
                if (!hasPermission) {
                    el.parentNode && el.parentNode.removeChild(el);
                }
            }
        } else {
            throw new Error(`need permissions! Like v-hasPermi="['view','edit']"`);
        }
    }
};
